diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 13:46:07 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 13:46:07 +0300 |
| commit | f100d259d2ffebe61fef56ea3964f6d534d598c8 (patch) | |
| tree | 09d06511506da9c35585740d56598eb542fac079 /src/pages/micro/[...page].astro | |
| parent | 1e5f5a953588cefa75396454c9aed0a79552db14 (diff) | |
Initial pleroma pull support
Diffstat (limited to 'src/pages/micro/[...page].astro')
| -rw-r--r-- | src/pages/micro/[...page].astro | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/pages/micro/[...page].astro b/src/pages/micro/[...page].astro index 08f5fd3..b4e3e07 100644 --- a/src/pages/micro/[...page].astro +++ b/src/pages/micro/[...page].astro @@ -1,20 +1,31 @@ --- import { type CollectionEntry, getCollection } from "astro:content"; -import Pagination from "@/components/Paginator.astro"; +import type { GetStaticPaths, Page } from "astro"; +import { Icon } from "astro-icon/components"; import Note from "@/components/note/Note.astro"; +import Pagination from "@/components/Paginator.astro"; import PageLayout from "@/layouts/Base.astro"; import { collectionDateSort } from "@/utils/date"; -import type { GetStaticPaths, Page } from "astro"; -import { Icon } from "astro-icon/components"; export const getStaticPaths = (async ({ paginate }) => { const MAX_MICRO_PER_PAGE = 10; - const allMicro = await getCollection("note"); - return paginate(allMicro.sort(collectionDateSort), { pageSize: MAX_MICRO_PER_PAGE }); + + // Get both local notes and Pleroma posts + const [allNotes, allMicro] = await Promise.all([ + getCollection("note"), + getCollection("micro").catch(() => []), // Fallback to empty array if micro collection fails + ]); + + // Combine and sort all micro posts + const allMicroPosts = [...allNotes, ...allMicro].sort( + (a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime(), + ); + + return paginate(allMicroPosts, { pageSize: MAX_MICRO_PER_PAGE }); }) satisfies GetStaticPaths; interface Props { - page: Page<CollectionEntry<"note">>; + page: Page<CollectionEntry<"note"> | CollectionEntry<"micro">>; uniqueTags: string[]; } |
